package com.woniuxy.charin.controller;

import com.woniuxy.charin.model.entity.StationFeeStandard;
import com.woniuxy.charin.service.StationFeeStandardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/stationFeeStandard")
@Slf4j
@Api(tags = "充电站收费标准管理")
public class StationFeeStandardController {
    @Autowired
    private StationFeeStandardService stationFeeStandardService;

    //根据站点id查询收费标准
    @GetMapping("/getStationFeeStandardByStationId")
    @ApiOperation("根据站点id查询收费标准")
    public List<StationFeeStandard> getStationFeeStandardByStationId(Integer stationId, int page, int size) {
        log.info("根据站点id查询收费标准");
        return stationFeeStandardService.getStationFeeStandardByStationId(stationId, page, size);
    }

    //分页查询
    @GetMapping("/getStationFeeStandardByPage")
    @ApiOperation("分页查询所有收费标准信息")
    public List<StationFeeStandard> getStationFeeStandardList(int page, int size) {
        log.info("分页查询收费标准信息");
        return stationFeeStandardService.getStationFeeStandardList(page, size);
    }

    //删除收费标准
    @DeleteMapping("/deleteStationFeeStandard")
    @ApiOperation("删除收费标准")
    public String deleteStationFeeStandard(Integer id) {
        log.info("删除收费标准");
        stationFeeStandardService.deleteStationFeeStandard(id);
        return "删除成功";
    }

    //新增收费标准
    @PostMapping("/addStationFeeStandard")
    @ApiOperation("新增收费标准")
    public String addStationFeeStandard(StationFeeStandard stationFeeStandard) {
        log.info("新增收费标准");
        stationFeeStandardService.addStationFeeStandard(stationFeeStandard);
        return "新增成功";
    }

    //修改收费标准
    @PutMapping("/updateStationFeeStandard")
    @ApiOperation("修改收费标准")
    public String updateStationFeeStandard(@RequestBody StationFeeStandard stationFeeStandard) {
        log.info("修改收费标准");
        log.info("updateStationFeeStandard: {}", stationFeeStandard);
        stationFeeStandardService.updateStationFeeStandard(stationFeeStandard);
        return "修改成功！";
    }

}
